﻿<%@ Page Title="Management Style" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="StyleManagement.aspx.cs" Inherits="Admin_StyleManagement" %>

<%@ Register Assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.DynamicData" TagPrefix="cc1" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<telerik:RadCodeBlock ID="block1" runat="server">
    <script type="text/javascript">
        function OnClientFocus(sender) {
            var combo = $find('<%=RadComboBox1.ClientID %>');
            var content = combo.get_text();
            if (content == "Nhập vào từ khóa cần tìm") {
                combo.set_text("");
            }
        }
        function OnClientBlur(sender, args) {
            var combo = $find('<%=RadComboBox1.ClientID %>');
            var content = combo.get_text();
            if (content == "") {
                combo.set_text("Nhập vào từ khóa cần tìm");
            }
        }
    </script>
</telerik:RadCodeBlock>
    <div>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:EatDrinkConnectionString %>" 
            SelectCommand="SELECT * FROM [Style]"></asp:SqlDataSource>
        <div align="right">
            <telerik:radcombobox 
                id="RadComboBox1" 
                Runat="server" 
                Height="140px" 
                Width="250px"
                ForeColor="#BDBDBD"
                DataSourceID="SqlDataSource2" 
                DataTextField="StyleName"
                ToolTip="Chọn kiểu quán"
                Skin="Outlook"
                AllowCustomText = "true"
                MarkFirstMatch="True" OnDataBound="RadComboBox1_DataBound"
                OnClientFocus="OnClientFocus"
                OnClientBlur="OnClientBlur">
            </telerik:radcombobox>&nbsp;&nbsp;
            <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" Height="21px" OnClick="btnSearch_Click" />
        </div>
        <telerik:RadGrid ID="uxStyle" runat="server" Skin="Office2007" AutoGenerateColumns="false"
            AllowPaging="true" PageSize="10" AllowSorting="true" ShowStatusBar="true" 
            PagerStyle-Mode="NextPrevNumericAndAdvanced" 
            onneeddatasource="uxStyle_NeedDataSource" 
            onupdatecommand="uxStyle_UpdateCommand" 
            oninsertcommand="uxStyle_InsertCommand"
            OnItemCreated="uxStyle_ItemCreated" onitemcommand="uxStyle_ItemCommand">
            <MasterTableView DataKeyNames="StyleID" CommandItemDisplay="TopAndBottom">
                <CommandItemTemplate>
                    <asp:LinkButton Style="vertical-align: bottom" ID="btnViewAll" runat="server"
                        CausesValidation="false" CommandName="ViewAll" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/view.gif" height="10" width="10"/>&nbsp;Xem tất cả
                    </asp:LinkButton>&nbsp;&nbsp;
                    <asp:LinkButton Style="vertical-align: bottom" ID="btnRefresh" runat="server"
                        CausesValidation="false" CommandName="RebindGrid" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Refresh.gif" height="9" width="9"/>&nbsp;Refresh
                    </asp:LinkButton>&nbsp;&nbsp;
                    <asp:LinkButton Style="vertical-align: bottom" ID="LinkButton1" runat="server"
                        CausesValidation="false" CommandName="InitInsert" ForeColor="#58ACFA">
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/AddRecord.gif" height="10" width="10"/>&nbsp;Thêm mới
                    </asp:LinkButton>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn Visible="false" DataField="StyleID" UniqueName="StyleID" HeaderText="StyleID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn Visible="true" DataField="StyleName" UniqueName="StyleName" HeaderText="StyleName">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table>
                            <tr>
                                <td>StyleName : </td>
                                <td>
                                    <asp:TextBox ID="txtStyleName" runat="server" Text='<%#Eval("StyleName") %>'></asp:TextBox><br />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Tên Style không được để trống" ControlToValidate="txtStyleName" ForeColor="Red" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:Label ID="lbError" runat="server" Visible="false" ForeColor="Red">Tên style bị trùng. Vui lòng kiểm tra lại</asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                     CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                     &nbsp;
                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" CommandName="Cancel"/>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
            Width="75px">
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
                style="border: 0px;" />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="uxStyle">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="uxStyle" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
    </div>
</asp:Content>